﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CSharpDesign.DAL;
using CSharpDesign.Scripts;

namespace CSharpDesign
{
    public partial class ZhuCe : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = " 水果商店";

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlDataReader dr = data.GetDataReader("select * from Users where UserName='" + txtname.Text + "' ");
            if (dr.Read())
            {
                Label1.Text = "账号已经存在";
                return;
            }
            SqlDataReader dr1 = data.GetDataReader("select * from Users where emal='" + txtemal.Text + "' ");
            if (dr1.Read())
            {
                Label1.Text = "注册邮箱已经存在";
                return;
            }
            else
            {
                data.RunSql("insert into Users(emal,UserName,Sex,Age,Ds,pwd,XingMing,SP,Address,ShengRi)values('" + txtemal.Text + "','" + txtname.Text + "','" + DropDownList1.SelectedItem.Text + "','" + Age.Text + "','" + txtds.Text + "','" + TextBox1.Text + "','" + XingMing.Text + "','" + SP.Text + "','" + Address.Text + "','" + txttime.Value + "')");

                Alert.AlertAndRedirect("注册成功！", "Default.aspx");
            }
        }

    }

}